package com.main;

import java.util.List;

import org.testng.Assert;

import com.restfb.Connection;
import com.restfb.DefaultFacebookClient;
import com.restfb.FacebookClient;
import com.restfb.types.Event;

public class TestEvents {
	private static List<EventObject> eventObjectList;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		FacebookClient fc = getClient();
		
		Events event = new Events(fc);
		
		Connection<Event> events = fc.fetchConnection("me/event", Event.class);
		List<Event> eventList = events.getData();
		for( Event ent : eventList){
			eventObjectList.add(new EventObject(ent.getId(), ent.getName(), ent.getStartTime()));
		}
		
		List<EventObject> eventsList = event.getEventList();

		for(EventObject ents : eventsList){
			for(EventObject entObjs : eventObjectList){
				if(ents.getId() == entObjs.getId()){
					Assert.assertEquals(ents.getName(), entObjs.getName(), "verify that the event has correct name");
					Assert.assertEquals(ents.getDate(), entObjs.getDate(), "verify that the event has correct Date");
				}
			}
		}
	}
	
	//This method is for testing purposes only.
	private static FacebookClient getClient()
	{
		String accessToken = "105537722501|2.gefBYYYY1LjqYSH4J8zCyw__.3600.1299272400-1220327113|-cKNVD3i_nf9zLpfdsh3DqwR5QU";
	    return new DefaultFacebookClient(accessToken);
	}

}
